<template>
	<view>
        <view class="u-page" v-if="listPageConfig">
            <commonListPage :config="listPageConfig" ref="mylp"></commonListPage>
        </view>
	</view>
</template>

<script>
    import commonListPage from '@/components/commonListPage/commonListPage.vue';
	export default {
		components: {
            commonListPage: commonListPage
        },
		data() {
			return {
				listPageConfig: ''
			}
		},
		onLoad(options) {
			var vm = this;
			vm.pageOptions = options;
            vm.doWxLogin().then(res => {
                vm.openId = res.openId;
				vm.initConfig()
            })
		},
		onShow: function () {
			// this.changeNavbarColor();
		},
		onPullDownRefresh: function () {
			this.$refs.mylp.getList(true);
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 500);
		},
		onReachBottom() {
           this.$refs.mylp.cmpReachBottom();
        },

		options: { styleIsolation: 'shared' },
		methods: {
			initConfig () {
				var vm = this;
				var options = vm.pageOptions;
				if (options.query) {
					var queryObj = JSON.parse(decodeURIComponent(options.query));
					Object.assign(options, queryObj);
					vm.listPageConfig = options;
					if (options.title) {
						uni.setNavigationBarTitle({
							title: options.title
						});
					}
				} else {
					var loadJSON = vm.pageOptions.loadJSON || '/mobile/mpoa/content/config.json';
					vm.getAndLoad('获取列表页配置', loadJSON, function (res) {
						Object.assign(res, options);
						vm.listPageConfig = res;
						if (res.title) {
							uni.setNavigationBarTitle({
								title: res.title
							});
						}
						vm.pageOptions = res;
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>

